package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 模板应用场景枚举
 */
public enum TemplateApplicationScenario implements BaseEnum {
    GRADE_EXPORT("GRADE_EXPORT", "成绩导出"),
    STATISTICS_REPORT("STATISTICS_REPORT", "统计报告"),
    EXAM_ANALYSIS("EXAM_ANALYSIS", "考试分析"),
    CERTIFICATE("CERTIFICATE", "证书生成"),
    TRANSCRIPT("TRANSCRIPT", "成绩单"),
    ACHIEVEMENT("ACHIEVEMENT", "成就证明"),
    ASSESSMENT("ASSESSMENT", "评估报告"),
    DASHBOARD("DASHBOARD", "仪表板");

    private final String code;
    private final String description;

    TemplateApplicationScenario(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static TemplateApplicationScenario fromCode(String code) {
        for (TemplateApplicationScenario scenario : values()) {
            if (scenario.getCode().equals(code)) {
                return scenario;
            }
        }
        return GRADE_EXPORT; // 默认返回成绩导出
    }

    public static TemplateApplicationScenario fromDescription(String description) {
        for (TemplateApplicationScenario scenario : values()) {
            if (scenario.getDescription().equals(description)) {
                return scenario;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}